<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <title></title> 
  <link rel="stylesheet" type="text/css" href="/Apps/Mobile/View//Public/static/Signup/css/style.css">
  <link rel="stylesheet" type="text/css" href="/Apps/Mobile/View//Public/static/Signup/css/DateTimePicker.css" />
  <script type="text/javascript" src="/Apps/Mobile/View//Public/static/Signup/js/fontResize.js"></script>
  <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  <script type="text/javascript" src="/Apps/Mobile/View//Public/static/Signup/js/DateTimePicker.js"></script>
  <script type="text/javascript" src="https://cdn-hangzhou.goeasy.io/goeasy.js"></script>
  <script type="text/javascript">
        var goEasy = new GoEasy({
             appkey: 'BC-329c7d5594d3419e8a690796f1cddbac'
        });
  </script>
</head>
<body>

<div class="main-box">

  <img src="/Apps/Mobile/View//Public/static/Signup/images/back.png" class="back">
  <h3>预约看房</h3>

  <div class="main">
    <div class="Leftbox">
      <h5><?php echo ($title); ?></h5>

      <div class="room">
        <?php if(is_array($rooms)): $i = 0; $__LIST__ = $rooms;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$rooms): $mod = ($i % 2 );++$i;?><span><?php echo ($rooms["fanghao"]); ?></span><?php endforeach; endif; else: echo "" ;endif; ?>
        
        <p class="price" >
          <?php if(is_array($price)): $i = 0; $__LIST__ = $price;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$price): $mod = ($i % 2 );++$i;?><b>￥<?php echo ($price["jiage"]); ?></b><?php endforeach; endif; else: echo "" ;endif; ?>
          元/月
          </p>
        
      </div>
       <div class="floor">
        <!-- <span><?php echo ($area); ?>㎡</span> -->
        <span><?php echo ($floor); ?></span>
      </div>
    </div>

    <div class="Rightbox">
      <img src="/Public/<?php echo ($imgurl); ?>">
    </div>
  </div>

  <div class="form">
    <div class="form-group">
      <span>姓名</span>
      <input type="text" class="js-form-input" id="name" placeholder="怎么称呼您？" value="" />
    </div>
    <div class="form-group">
      <span>性别</span>
      <input type="text" class="js-form-input" id="sex" placeholder="先生/女士" value="" />
      <select id="select1" name="sex" >
        <option value="先生/女士">先生/女士</option>
        <option value="先生">先生</option>
        <option value="女士">女士</option>
      </select>
    </div>
    <div class="form-group">
      <span>电话</span>
      <input type="tel" class="js-form-input" name="telphone" id="telphone" placeholder="请输入手机号码" value="" />
    </div>
    <div class="form-group">
      <span>期望预约时间</span>
      <input type="text" name="date" data-field="date" class="js-form-input " id="date" value="" placeholder="期望预约时间" readonly>
    </div>
    <div class="form-group">       
      <input type="text" class="js-form-input" id="time" placeholder="- 请选择预约时间 -" value="" />  
        <select id="select2" name="time" >
          <option value="- 请选择预约时间 -">- 请选择预约时间 -</option>
          <option value="10:00 ~ 10:59">10:00 ~ 10:59</option>
          <option value="11:00 ~ 11:59">11:00 ~ 11:59</option>
          <option value="13:00 ~ 13:59">13:00 ~ 13:59</option>
          <option value="14:00 ~ 14:59">14:00 ~ 14:59</option>
          <option value="15:00 ~ 15:59">15:00 ~ 15:59</option>
          <option value="16:00 ~ 16:59">16:00 ~ 16:59</option>
        </select> 
    </div>

    <div class="form-group">
      <span>留言</span>
      <textarea id="textarea"  placeholder="如您有更多需求，可以在这里给管家留言"></textarea>
    </div>

    <div class="submit">预约看房</div>
  </div>
  
</div>

<div id="dtBox"></div><!-- 日历 -->

<div class="alert-mask">
  <div class="alert">
    <div class="alert-header">感谢关注好房东</div>
    <div class="alert-body"></div>
    <div class="alert-footer">确定</div>
  </div>
</div> 

<script type="text/javascript">
$(document).ready(function(){

  /*$('.room span').on('click',function(){
    $(this).addClass('roomOn').siblings().removeClass('roomOn');
  });*/

  $(".room span").on('click',function(){
    $(".room span").eq(".price b");
    $(".price b").hide().eq($(this).index()).css('display','inline-block');
    $(this).addClass('roomOn').siblings().removeClass('roomOn');
  });



  $("#dtBox").DateTimePicker({
    dateFormat: "yyyy-MM-dd",
    shortDayNames: ["", "", "", "", "", "", ""],
    fullDayNames: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
    shortMonthNames: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
    fullMonthNames: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],    
    titleContentDate: "设置日期",
    setButtonContent: "确定",
    clearButtonContent: "取消"
  });


  var tel = function (value) { // 大陆手机号码
      return /^(0|86|17951)?(13[0-9]|15[012356789]|17[0678]|18[0-9]|14[57])[0-9]{8}$/.test(value);
    }

  var $formInput = $('.js-form-input'),
    $alertMask = $('.alert-mask'),
    $alertBody = $alertMask.find('.alert-body');

  $(".submit").on('click',function(event){
    var isEmply = false;
    $.each($formInput, function(i, t){
      if ($(t).val().length == 0) {
        $alertBody.text($(t).attr('placeholder'));  
        $alertMask.show();
        isEmply = true;
        return false;
      }
      if($(t).attr('name') ==='telphone'){
        tel($(t).val())
        
        if(!tel($(t).val())){
          $alertMask.show();
          $alertBody.text('电话格式错误');  
          isEmply = true;
          return false;
        }
      }
    });
    if (isEmply){
            return false;
    }else{
      var recommend_url = '<?php echo U("Mobile/Signup/save");?>';
      var post = {
        room      :  $('.roomOn').text(),
        name      :  $("#name").val(),
        sex       :  $('#sex').val(),
        tel       :  $('#telphone').val(),
        date      :  $('#date').val(),
        time    :  $('#time').val(), 
        textarea  :  $("#textarea").val(),
        houseid   :  <?php echo ($houseid); ?>
        };
      $.post(recommend_url,post,function(data){
        if(data == 1){
          $alertMask.show();
          $alertBody.text('预约成功，您的预约我们已经收到，我们的客服将会尽快与您联系，如有疑问，欢迎点击屏幕下方致电预约热线。');
          goEasy.publish({
              channel: 'haofangdongyuyue',
              message: $("#name").val()+$('#sex').val()+'预约了'+$('#date').val()+$('#time').val()+'看<?php echo ($title); ?>的'+$('.roomOn').text()+'。联系电话：'+$('#telphone').val()
          });
          setTimeout(function(){
             window.location.href="http://hfd.fangbanghui.com/2.html";
           },3000);

        }else{
          $alertMask.show();
          $alertBody.text('预约失败');
        }
      },'json');  
    }
  });

  $('.alert-footer').on('click',function(){
    $alertMask.hide();
  });


  

  $("#select1").change(function () {
    var text = $('#select1 option:selected').text();//选中的文本
    $("#sex").val(text);
  });

  $("#select2").change(function () {
    var text = $('#select2 option:selected').text();//选中的文本
    $("#time").val(text);
  });


});
</script>





</body>
</html>